package basicx.oop.adt


/*-*- coding:utf-8 -*-
* @Author  : ygree 
* @Time    : 2021/7/2 0:09
* @Software : IntelliJ IDEA
*/
//枚举类
private enum class Week {
    x1, x2, x3, x4, x5, x6, x7, x8, x9
}

private enum class Directions(val opp: OperatorOverload) {
    EAST(OperatorOverload(1, 0)),
    WEST(OperatorOverload(-1, 0)),
    SOUTH(OperatorOverload(0, -1)),
    NORTH(OperatorOverload(0, 1));

    //函数
    fun updateOperator(op: OperatorOverload) = OperatorOverload(op.x + opp.x, op.y + opp.y)
}

private enum class LicenseStatus {
    //枚举--->添加属性-->密封
    Start,//不合格，
    Stop,
    Wait;
}

private class EnumDriver(var status: LicenseStatus) {
    fun checkLicense(): String {
        return when (status) {//需要添加其他分支
            LicenseStatus.Start -> "Start"
            LicenseStatus.Stop -> "Stop"
            LicenseStatus.Wait -> "Wait"
        }
    }
}

private  fun main() {
    println("Week.x1         ${Week.x1}") // x1
    println("Week.x1.ordinal ${Week.x1.ordinal}") // 0
    println("Week.x1.is      ${Week.x1 is Week}")
    println("------------")
    Directions.entries.forEach {
        println("${it} x ${it.opp.x} y ${it.opp.y}")
    }
    println("Directions.EAST      ${Directions.EAST}")
    println("Directions.EAST      ${Directions.EAST.updateOperator(OperatorOverload(2, 2))}")
    Directions.entries.forEach {
        println("${it} x ${it.opp.x} y ${it.opp.y}")
    }
    println("------------")
    println(EnumDriver(LicenseStatus.Wait).checkLicense())

}
